package com.ruoyi.jiajia.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JiajiaHomeActivity;
import com.ruoyi.system.service.IJiajiaHomeActivityService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 首页活动信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-07
 */
@Controller
@RequestMapping("/jiajia/JiajiaHomeActivity")
public class JiajiaHomeActivityController extends BaseController
{
    private String prefix = "jiajia/JiajiaHomeActivity";

    @Autowired
    private IJiajiaHomeActivityService jiajiaHomeActivityService;

    @RequiresPermissions("jiajia:JiajiaHomeActivity:view")
    @GetMapping()
    public String JiajiaHomeActivity()
    {
        return prefix + "/JiajiaHomeActivity";
    }

    /**
     * 查询首页活动信息列表
     */
    @RequiresPermissions("jiajia:JiajiaHomeActivity:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaHomeActivity jiajiaHomeActivity)
    {
        startPage();
        List<JiajiaHomeActivity> list = jiajiaHomeActivityService.selectJiajiaHomeActivityList(jiajiaHomeActivity);
        return getDataTable(list);
    }

    /**
     * 导出首页活动信息列表
     */
    @RequiresPermissions("jiajia:JiajiaHomeActivity:export")
    @Log(title = "首页活动信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaHomeActivity jiajiaHomeActivity)
    {
        List<JiajiaHomeActivity> list = jiajiaHomeActivityService.selectJiajiaHomeActivityList(jiajiaHomeActivity);
        ExcelUtil<JiajiaHomeActivity> util = new ExcelUtil<JiajiaHomeActivity>(JiajiaHomeActivity.class);
        return util.exportExcel(list, "首页活动信息数据");
    }

    /**
     * 新增首页活动信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存首页活动信息
     */
    @RequiresPermissions("jiajia:JiajiaHomeActivity:add")
    @Log(title = "首页活动信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaHomeActivity jiajiaHomeActivity)
    {
        return toAjax(jiajiaHomeActivityService.insertJiajiaHomeActivity(jiajiaHomeActivity));
    }

    /**
     * 修改首页活动信息
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaHomeActivity jiajiaHomeActivity = jiajiaHomeActivityService.selectJiajiaHomeActivityById(id);
        mmap.put("jiajiaHomeActivity", jiajiaHomeActivity);
        return prefix + "/edit";
    }

    /**
     * 修改保存首页活动信息
     */
    @RequiresPermissions("jiajia:JiajiaHomeActivity:edit")
    @Log(title = "首页活动信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaHomeActivity jiajiaHomeActivity)
    {
        return toAjax(jiajiaHomeActivityService.updateJiajiaHomeActivity(jiajiaHomeActivity));
    }

    /**
     * 删除首页活动信息
     */
    @RequiresPermissions("jiajia:JiajiaHomeActivity:remove")
    @Log(title = "首页活动信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaHomeActivityService.deleteJiajiaHomeActivityByIds(ids));
    }
}
